<?php


namespace app\api\controller\v21;


use app\api\controller\v13\Auth2;
use app\common\cachemodel\ZlRecommendDivination;
use app\common\cachemodel\ZlVisit;

class Divination extends Auth2
{
    protected $visitType = 3;
    /**
     * 获取推荐问题
     * @throws \Exception
     */
    public function getRecommendQuestion()
    {
        $type = input('type/d', 1); // 1=>骰子问题 2=>塔罗问题

        $recommendList = (new ZlRecommendDivination())->getRecommendQuestion($type);

        $resDAta = [
            'recommend_list' => $recommendList
        ];
        if ($type === 1)
        {
            $resDAta['img'] = '/test/tarot/divination1.png';
            $resDAta['title'] = '骰子提问';
        } elseif ($type === 2)
        {
            $resDAta['img'] = '/test/tarot/divination2.png';
            $resDAta['title'] = '三牌塔罗提问';
        }
        $distinctId = $this->request->header('distinct-id', '');
        if($distinctId)
        {
            $resDAta['is_first'] = (new ZlVisit())->getVisitData($this->user['id'], $this->visitType);
        }

        return show(config('code.success'), '请求成功', $resDAta);
    }
}
